function addGroupInfo(){
    var o = document.group;
    if(o.groupName.value.Trim()==''){
        alert('组名不能空');
        o.groupName.focus();
        return;
    }else if(o.info.value.Trim()==''){
        alert('组说明不能空');
        o.info.focus();
        return;
    }

    var flag = false;
    var value="";
    for (var i=0;i<o.elements.length;i++) {
        var temp=o[i];
        if(temp.type=="checkbox"&&temp.checked&&temp.name=="second_menu") {
            flag = true;
            value += temp.value+",";
        }
    }

    if(!flag){
        if(confirm('您确认不为该组添加任何权限吗？')){
            manage.addGroup(o.groupName.value,o.info.value,"",function(data){
                if(data==1){
                    alert("管理员组“"+o.groupName.value+"”添加成功！");
                    window.location.href='groupList.jsp';
                }else if(data==0){
                    alert('未知原因，分组添加失败！');
                }else if(data==-1){
                    alert('组“'+o.groupName.value+'”已经存在，添加失败！');
                }
            });
        }
    }else{
        manage.addGroup(o.groupName.value,o.info.value,value,function(data){
            if(data==1){
                alert("管理员组“"+o.groupName.value+"”添加成功！");
                window.location.href='groupList.jsp';
            }else if(data==0){
                alert('未知原因，分组添加失败！');
            }else if(data==-1){
                alert('组“'+o.groupName.value+'”已经存在，添加失败！');
            }else if(data==-2){
                alert('组“'+o.groupName.value+'”权限分配失败！');
                window.location.href='group.jsp?type=edit&name='+_E(o.groupName.value);
            }else if(data==-3){
                alert('组“'+o.groupName.value+'”部分权限分配失败！');
                window.location.href='group.jsp?type=edit&name='+_E(o.groupName.value);
            }
        });
    }
}

function editGroupInfo(){
    var o = document.group;
    if(o.groupName.value.Trim()==''){
        alert('组名不能空！');
        o.groupName.focus();
        return;
    }else if(o.info.value.Trim()==''){
        alert('组说明不能空！');
        o.info.focus();
        return;
    }

    var flag = false;
    var value="";
    for (var i=0;i<o.elements.length;i++) {
        var temp=o[i];
        if(temp.type=="checkbox"&&temp.checked&&temp.name=="second_menu") {
            flag = true;
            value += temp.value+",";
        }
    }

    if(!flag){
        if(confirm('您确认不为该组赋予任何权限吗\uff1f')){
            manage.editGroup(o.oldName.value,o.groupName.value,o.info.value,"",function(data){
                if(data==1){
                    alert("管理员组“"+o.groupName.value+"”修改成功\uff01");
                    window.location.reload();
                }else if(data==0){
                    alert('未知原因，分组添加失败\uff01');
                }else if(data==-1){
                    alert('组“'+o.groupName.value+'”已经存在，添加失败\uff01');
                }
            });
        }
    }else{
        manage.editGroup(o.oldName.value,o.groupName.value,o.info.value,value,function(data){
            if(data==1){
                alert("管理员组“"+o.groupName.value+"”修改成功\uff01");
                window.location.href='group.jsp?type=edit&name='+_E(o.groupName.value);
            }else if(data==0){
                alert('未知原因，分组修改失败\uff01');
            }else if(data==-1){
                alert('组“'+o.groupName.value+'”已经存在，添加失败\uff01');
            }else if(data==-2){
                alert('组“'+o.groupName.value+'”权限分配失败\uff01');
                window.location.href='group.jsp?type=edit&name='+_E(o.groupName.value);
            }else if(data==-3){
                alert('组“'+o.groupName.value+'”部分权限分配失败\uff01');
                window.location.href='group.jsp?type=edit&name='+_E(o.groupName.value);
            }
        });
    }
}

function deleteGroup(name){
    if(name!=""){
        manage.deleteGroup(name,function(data){
            if(data==1){
                alert("\u7ec4\u201c"+_D(name)+"\u201d\u5220\u9664\u6210\u529f\uff01");
                window.location.reload();
            }else{
                alert("组“"+_D(name)+"”删除失败\uff01");
            }
        });
    }else{
        alert("\u5220\u9664\u5931\u8d25\uff01");
    }
}